package top.fullj.actor.mq;

public class InMemoryChannel<T> implements Channel<T> {

    private final Subscribers<T> subscribers = new Subscribers<>();

    @Override
    public void publish(T msg) {
        subscribers.publish(msg);
    }

    @Override
    public void subscribe(Fiber fiber, Action<T> action) {
        subscribers.add(new Subscription<>(fiber, action));
    }

    @Override
    public void clearSubscribers() {
        subscribers.clear();
    }

}
